home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / 80x0393.zip / EXTFILE.ASM < prev    next >
Assembly Source File  |  1992-07-30  |  3KB  |  103 lines

  1. comment *
  2.    EXTFILE.ASM
  3.  
  4.    EXTERNAL FILE for use with:
  5.    IRQVECT.ASM
  6.    VCP_DERT.ASM
  7.  
  8.    Author:
  9.    Yousuf Khan, released to the public domain
  10. *
  11.  
  12.         .model tiny
  13.  
  14. public  vcpi_detect
  15.  
  16.         .data
  17.         emm_name        db      'EMMXXXX0', 0
  18.         org 100h
  19.         .code
  20.  
  21. vcpi_detect     proc    near
  22.  
  23. comment *
  24.     Purpose:
  25.     Detects whether a VCPI host is installed.
  26.  
  27.     Entry:
  28.     nothing
  29.  
  30.     Destroys:
  31.     BX, DX
  32.  
  33.     Returns:
  34.     AX=0    if VCPI installed
  35.     AX=-1   if VCPI not installed
  36. *
  37.  
  38.         pushf
  39.         xor     ax, ax
  40.         push    ax
  41.         popf
  42.         pushf
  43.         pop     ax
  44.         test    ax, 0f000h
  45.         je      short not_386   ;upper four bits of FLAG register not
  46.                                 ;settable, must be less than a 386
  47.         popf
  48.         jmp     short ems_check
  49.  
  50. not_386:
  51.         popf                    ;No 386? Can't have VCPI either
  52.         jmp     no_vcpi
  53.  
  54. ems_check:
  55.         lea     dx, emm_name    ;"EMMXXXX0" name of handle to open
  56.         mov     ax, 3d00h
  57.         int     21h             ;open file handle
  58.         jc      short no_vcpi   ;handle not found, must be no EMS
  59.         mov     bx, ax          ;store file handle # in BX
  60.         mov     ax, 4400h       ;IOCTL: get device info
  61.         int     21h
  62.         jc      short no_vcpi   ;error occurred, must be no EMS
  63.         test    dx, 80h         ;if 7th bit clear, file handle must
  64.         jz      short no_vcpi   ; be disk file not character device
  65.         mov     ax, 4407h
  66.         int     21h
  67.         push    ax              ;store result of fnct.
  68.         mov     ah, 3eh
  69.         int     21h             ;close file handle
  70.         pop     ax
  71.         cmp     al, 0ffh        ;EMS device ready? If yes, AL=0FFh.
  72.         jne     short no_vcpi
  73.         ;
  74.         ;Now we found an EMS driver is installed. But is it VCPI?
  75.         ;
  76.         mov     bx, 1           ;# of pages to allocate
  77.         mov     ah, 43h         ;get EMS handle and allocate
  78.         int     67h             ; memory
  79.         cmp     ah, 0           ;function completed successfully
  80.         jne     short no_vcpi
  81.         push    dx              ;save EMS handle
  82.         mov     ax, 0de00h      ;VCPI installation check fnct.
  83.         int     67h
  84.         pop     dx              ;retrieve EMS handle
  85.         push    ax              ;save VCPI detection flag
  86.         mov     ah, 45h
  87.         int     67h             ;release EMS handle
  88.         pop     ax
  89.         cmp     ah, 0
  90.         jne     short no_vcpi   ;if AH<>0, no VCPI
  91.         xor     ax, ax          ;set AX=0 if VCPI present
  92.         jmp     short exit_tests
  93.  
  94. no_vcpi:
  95.         mov     ax, -1          ;set AX=1 if VCPI not present
  96.  
  97. exit_tests:
  98.         ret
  99.         endp
  100.         end
  101.  
  102. ; EOF EXTFILE.ASM
  103.